<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Fenhuigrade\Fenhuigrade;
use kartik\file\FileInput;//图片上传
use \kucha\ueditor\UEditor;
/* @var $this yii\web\View */
/* @var $model common\models\Fenhuigrade\Fenhuigrade */
/* @var $form yii\widgets\ActiveForm */
?>
<style>
.kv-file-content img{ width: 100%!important; }
</style>
<div class="fenhuigrade-form">

    <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'],'id'=>'subform']); ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

	<?php
        if(isset(json_decode($model->label_img)->newname)){
            $img = json_decode($model->label_img)->newname;
        }else{
            $img = $model->label_img;
        }
        $siteRoot = Yii::$app->params['qtimg'];
        echo '<label class="control-label">照片(格式:98**98,以像在图片中部的半身像为佳)</label>;';
        echo FileInput::widget([
            'model' => $model,
            'attribute' => 'label_img',
            'options' => ['accept' => 'image/*'],
            'pluginOptions' => [
                'uploadExtraData' => [
                    'album_id' => 20,
                    'cat_id' => 'Nature'
                ],
                'initialPreview'=>[
                    !empty($img)?Html::img(Yii::$app->params['qtimg'].$img):null,
                ],
                'initialCaption'=> $img,
                'maxFileCount' => 10,
                "showUpload"=> false,
            ]
        ]);
    ?>	

    <?= $form->field($model,'content')->widget('kucha\ueditor\UEditor',[]); ?>


    <?= $form->field($model, 'status')->dropDownList(Fenhuigrade::getArrayStatus()) ?>


    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
